package com.ycw.controller.CJY;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ycw.bean.Comments;
import com.ycw.service.CJY.CommentsService;
import com.ycw.util.Msg;

@Controller
public class CommentsController {
	@Autowired
	CommentsService commentsService;
	
	//查询所有评论信息  分页展示
	@RequestMapping("/getAllComments")
	@ResponseBody
	public Msg getAllComments(@RequestParam(value="page",defaultValue="1")Integer page){
		//引入 pageHelper
		PageHelper.startPage(page, 10);
		List<Comments> list=commentsService.getALLComments(); 

		//分页插件
		PageInfo pageInfo = new PageInfo(list);

		return Msg.success().add("pageInfo", pageInfo);
		
	}
	
	//删除评论
	@RequestMapping("/deleteCommentsById")
	@ResponseBody
	public Msg deleteComments(Comments comments) {
		commentsService.deleteComments(comments);
		return Msg.success();
	}
}
